package com.huage.xml;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class JsoupDemo {
    public static void main(String[] args) throws IOException {
        String path = JsoupDemo.class.getClassLoader().getResource("Users.xml").getPath();
        Document document = Jsoup.parse(new File(path), "UTF-8");
        Elements elements = document.getElementsByTag("user");
        for (Element element : elements) {
            String name = element.getElementsByTag("name").text();
            String age = element.getElementsByTag("age").text();
            String gender = element.getElementsByTag("gender").text();
            System.out.println(name+":"+age+":"+gender);
        }
    }
}
